﻿using GalaSoft.MvvmLight;
using System.Collections.Generic;
using System;
using ASoft.Data;
using System.Windows.Media;

namespace ASoft.WPF.ViewModel
{
    /// <summary>
    /// This class contains properties that a View can data bind to.
    /// <para>
    /// Use the <strong>mvvminpc</strong> snippet to add bindable properties to this ViewModel.
    /// </para>
    /// <para>
    /// You can also use Blend to data bind with the tool's support.
    /// </para>
    /// <para>
    /// See http://www.galasoft.ch/mvvm/getstarted
    /// </para>
    /// </summary>
    public class WeatherStationInfoMsgViewModelBase : ViewModelBase
    {

        #region "光照

        /// <summary>
        /// The <see cref="光照" /> property's name.
        /// </summary>
        public const string 光照PropertyName = "光照";

        private System.Int16 _光照 = default(System.Int16);

        /// <summary>
        /// Gets the 光照 property.
        /// </summary>
        public System.Int16 光照
        {
            get
            {
                return _光照;
            }

            set
            {
                if (_光照 == value)
                {
                    return;
                }

                var oldValue = _光照;
                _光照 = value;

                RaisePropertyChanged(光照PropertyName);
            }
        }

        #endregion


        #region "雨雪

        /// <summary>
        /// The <see cref="雨雪" /> property's name.
        /// </summary>
        public const string 雨雪PropertyName = "雨雪";

        private System.Byte _雨雪 = default(System.Byte);

        /// <summary>
        /// Gets the 雨雪 property.
        /// </summary>
        public System.Byte 雨雪
        {
            get
            {
                return _雨雪;
            }

            set
            {
                if (_雨雪 == value)
                {
                    return;
                }

                var oldValue = _雨雪;
                _雨雪 = value;

                RaisePropertyChanged(雨雪PropertyName);
                RaisePropertyChanged("雨雪字符串");
            }
        }

        #endregion

        public Dictionary<byte, string> 雨雪Source
        {
            get
            {
                return AppUtility.雨雪集合;
            }
        }

        public Dictionary<byte, string> 风向Source
        {
            get
            {
                return AppUtility.风向集合;
            }
        }


        #region "风速

        /// <summary>
        /// The <see cref="风速" /> property's name.
        /// </summary>
        public const string 风速PropertyName = "风速";

        private System.Decimal _风速 = default(System.Decimal);

        /// <summary>
        /// Gets the 风速 property.
        /// </summary>
        public System.Decimal 风速
        {
            get
            {
                return _风速;
            }

            set
            {
                if (_风速 == value)
                {
                    return;
                }

                var oldValue = _风速;
                _风速 = value;

                RaisePropertyChanged(风速PropertyName);
            }
        }

        #endregion


        #region "风向

        /// <summary>
        /// The <see cref="风向" /> property's name.
        /// </summary>
        public const string 风向PropertyName = "风向";

        private System.Byte _风向 = default(System.Byte);

        /// <summary>
        /// Gets the 风向 property.
        /// </summary>
        public System.Byte 风向
        {
            get
            {
                return _风向;
            }

            set
            {
                if (_风向 == value)
                {
                    return;
                }

                var oldValue = _风向;
                _风向 = value;

                RaisePropertyChanged(风向PropertyName);
                RaisePropertyChanged("风向字符串");
            }
        }

        #endregion


        #region "室外温度

        /// <summary>
        /// The <see cref="室外温度" /> property's name.
        /// </summary>
        public const string 室外温度PropertyName = "室外温度";

        private System.Decimal _室外温度 = default(System.Decimal);

        /// <summary>
        /// Gets the 室外温度 property.
        /// </summary>
        public System.Decimal 室外温度
        {
            get
            {
                return _室外温度;
            }

            set
            {
                if (_室外温度 == value)
                {
                    return;
                }

                var oldValue = _室外温度;
                _室外温度 = value;

                RaisePropertyChanged(室外温度PropertyName);
            }
        }

        #endregion


        #region "大风报警位

        /// <summary>
        /// The <see cref="大风报警位" /> property's name.
        /// </summary>
        public const string 大风报警位PropertyName = "大风报警位";

        private System.Byte _大风报警位 = default(System.Byte);

        /// <summary>
        /// Gets the 大风报警位 property.
        /// </summary>
        public System.Byte 大风报警位
        {
            get
            {
                return _大风报警位;
            }

            set
            {
                if (_大风报警位 == value)
                {
                    return;
                }

                var oldValue = _大风报警位;
                _大风报警位 = value;

                RaisePropertyChanged(大风报警位PropertyName);
            }
        }

        #endregion


        #region "室外湿度

        /// <summary>
        /// The <see cref="室外湿度" /> property's name.
        /// </summary>
        public const string 室外湿度PropertyName = "室外湿度";

        private System.Byte _室外湿度 = default(System.Byte);

        /// <summary>
        /// Gets the 室外湿度 property.
        /// </summary>
        public System.Byte 室外湿度
        {
            get
            {
                return _室外湿度;
            }

            set
            {
                if (_室外湿度 == value)
                {
                    return;
                }

                var oldValue = _室外湿度;
                _室外湿度 = value;

                RaisePropertyChanged(室外湿度PropertyName);
            }
        }

        #endregion


        public string 风向字符串
        {
            get
            {
                return 风向Source[风向];
            }
        }

        public string 雨雪字符串
        {
            get
            {
                return 雨雪Source[雨雪];
            }
        }

        #region "Left"

        public Double Left
        {
            get
            {
                return RC.Current.PositionData.PositionWeatherStation.Left;
            }
            set
            {
                if (RC.Current.PositionData.PositionWeatherStation.Left == value)
                {
                    return;
                }
                RC.Current.PositionData.PositionWeatherStation.Left = value;
                RC.Current.SavePositionData();
                RaisePropertyChanged("Left");
            }
        }

        #endregion

        #region "Top"

        public Double Top
        {
            get
            {
                return RC.Current.PositionData.PositionWeatherStation.Top;
            }
            set
            {
                if (RC.Current.PositionData.PositionWeatherStation.Top == value)
                {
                    return;
                }
                RC.Current.PositionData.PositionWeatherStation.Top = value;
                RC.Current.SavePositionData();
                RaisePropertyChanged("Top");
            }
        }

        #endregion

        #region "检测结果"

        private ECheckFlag _检测结果 = ECheckFlag.未检测;

        public ECheckFlag 检测结果
        {
            get
            {
                return _检测结果;
            }
            set
            {
                if (_检测结果 == value)
                {
                    return;
                }

                var oldValue = _检测结果;
                _检测结果 = value;

                RaisePropertyChanged("检测结果");
                RaisePropertyChanged("检测结果的颜色");
            }
        }

        public SolidColorBrush 检测结果的颜色
        {
            get
            {
                switch (this.检测结果)
                {
                    case ECheckFlag.未检测:
                        return new SolidColorBrush(Colors.Yellow);
                    case ECheckFlag.成功:
                        return new SolidColorBrush(Colors.Green);
                    case ECheckFlag.失败:
                        return new SolidColorBrush(Colors.Red);
                    case ECheckFlag.模似:
                        return new SolidColorBrush(Colors.Blue);
                    default:
                        throw new NotImplementedException();
                }
            }
        }

        #endregion
    }
}